package com.android.component;

import com.utils.LogUtil;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class CommonTest extends Activity implements OnClickListener {
    Button btns[] = new Button[6];
    Button btn_clearButton = null;
    TextView tv_log = null;

    int btn_count = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.common_test);

        tv_log = (TextView) findViewById(R.id.tvlog);
        btn_clearButton = (Button) findViewById(R.id.clear);
        btns[0] = (Button) findViewById(R.id.btn1);
        btns[1] = (Button) findViewById(R.id.btn2);
        btns[2] = (Button) findViewById(R.id.btn3);
        btns[3] = (Button) findViewById(R.id.btn4);
        btns[4] = (Button) findViewById(R.id.btn5);
        btns[5] = (Button) findViewById(R.id.btn6);

        btn_clearButton.setOnClickListener(this);
        LogUtil.setTv(tv_log);
    }

    protected void setButton(String text, OnClickListener l) {
        Button btn = btns[btn_count++];
        btn.setText(text);
        btn.setOnClickListener(l);
        btn.setVisibility(View.VISIBLE);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.clear) {
            btn_clearButton.setText("");
        }
    }
}
